<?php
namespace Admin\Controller;
use Think\Controller;
class ClubadminsController extends Controller {
    public function clubadmins(){

        $club_adminsModel=M('Club_admins');//构建一个操作club_admins表的模型实例
        $Club_admins=$club_adminsModel->order('ca_id ')->select();
        $this->Club_admins=$Club_admins;
        $this->display();
    }
        public function addclubadmins()
  {
    if(IS_POST)
    {
      
      $data['ca_name'] = I('post.ca_name');
      $data['gender'] = I('post.ca_gender');
      $password = I('post.ca_password');
      $data['tel'] = I('post.ca_tel');
      
      
      if(empty($data['ca_name']))
      {
        $this->error('用户名必须填写');
      }
      else
      { 
        $addclubadmins= M('Club_admins');
        if($addclubadmins->create()){
          
            if(false!==$addclubadmins->add())
                      {
                $this->success('添加成功!','clubadmins');
            }
            else{$this->error('添加失败');}
        }else{
            $this->error($addclubadmins->getError());
        }
      }
    }
    else
    { 
      $this->display();
    } }   
    public function Delclubadmins($ca_id){
       // $id=$_GET['id'];
    $club_adminsmodel=M('Club_admins'); 
    //where实在构建条件
    if(false!==$club_adminsmodel->where("ca_id=$ca_id"/*必须是双引号*/)->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
        
    }
}
?>